package ma.cdm.compteRendu.bo;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import org.hibernate.annotations.GenericGenerator;

/**
 * Action entity. @author Limouri Anouar
 */
@Entity
@Table(name="action")

public class Action  implements java.io.Serializable {

	// Fields

	private Long idaction;
	private String libelleaction;
	private String descriptionaction;
	private Set<Role> roles = new HashSet<Role>(0);

	// Constructors

	/** default constructor */
	public Action() {
	}

	/** full constructor */
	public Action(String libelleaction, String descriptionaction,
			Set<Role> roles) {
		this.libelleaction = libelleaction;
		this.descriptionaction = descriptionaction;
		this.roles = roles;
	}

	// Property accessors
	@GenericGenerator(name = "generator", strategy = "increment")
	@Id
	@GeneratedValue(generator = "generator")
	@Column(name = "IDACTION", unique = true, nullable = false)
	public Long getIdaction() {
		return this.idaction;
	}

	public void setIdaction(Long idaction) {
		this.idaction = idaction;
	}

	@Column(name = "LIBELLEACTION", length = 50)
	public String getLibelleaction() {
		return this.libelleaction;
	}

	public void setLibelleaction(String libelleaction) {
		this.libelleaction = libelleaction;
	}

	@Column(name = "DESCRIPTIONACTION", length = 100)
	public String getDescriptionaction() {
		return this.descriptionaction;
	}

	public void setDescriptionaction(String descriptionaction) {
		this.descriptionaction = descriptionaction;
	}

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "actions")
	public Set<Role> getRoles() {
		return this.roles;
	}

	public void setRoles(Set<Role> roles) {
		this.roles = roles;
	}

}